<!--售票员层级差异待协查-->
<template>
  <div class="shouPiaoYuanPKCYDXC HuikuiInfo el-card is-always-shadow el-card__body">
    <el-dialog
      title="操作回馈信息"
      :visible.sync="dialogVisible"
      @close="closed"
      width="950px">
      <avue-form v-if="isReload" class="shouPiaoYuanPKCYDXCForm" :option="option" v-model="formData" @submit="handleSubmit">
        <template slot-scope="scope" slot="list1" >
          <avue-crud
            ref="crud"
            :option="cols1"
            :data="formData.list1">
          </avue-crud>
        </template>
        <template slot-scope="scope" slot="menuForm" >
          <el-button type="primary" v-if="permissionList.replaceContent && (formData.assistCategory=='1' || (formData.assistState=='8' && formData.assistCategory=='3')) && formData.replaceStatus==0 && formData.jdReplySatus == 1" @click="handleSubmit" >一键替换</el-button>
          <el-button  @click="closed" >返回</el-button>
        </template>
      </avue-form>
    </el-dialog>
  </div>
</template>

<script>
  import {getForm, postForm} from '@/api/gen/gen'
  import ExportJsonExcel from "js-export-excel";
  import {clearSelect, electromeReasons, getElectromeReasons} from "../../../../../api/subwayRat/commonCheck";
  import {
    cols1,
    replaceSwAuConductorToBeChecked
  } from "../../../../../api/subwayRat/conductorDifferences/conductorTicketChaYiShenhe/shouPiaoYuanCJDXY/shouPiaoYuanPKCYDXC/shouPiaoYuanPKCYDXC";
  import {mapGetters} from "vuex";

  export default {
    components:{
    },
    data() {
      return {
        isReload:true,
        showType:1,
        cols1:cols1,
        replaceStatus:1,
        dialogVisible:true,
        assistState:0,
	assistCategory:0,
        formData:{
          list1:[],
        },
        option:{

        }
    }
    },
    computed: {
      ...mapGetters(["permissions"]),
      permissionList () {
        return {
          replaceContent: this.vaildData(
            this.permissions.shouPiaoYuan_PKCYDXC_one_click_replacement,
            false
          )
        };
      },
    },
    created() {
  
    },
    methods: {
      handleSubmit(){
        if (this.formData.jdReplySatus != 1) {
          this.$message.error("机电专业尚未反馈！");
          return;
        }
        if (this.formData.assistState != 8 && this.formData.assistCategory==3) {
          this.$message.error("当前数据非部门审核通过！");
          return;
        }
        replaceSwAuConductorToBeChecked({ids:this.formData.id}).then(res=>{
          if(res.data.code==0){
            this.$message.success("操作成功！");
            this.closed();
            this.$parent.getList();
          }else{
            this.$message.error(res.data.msg);
          }
        })
      },
      recallShow(row){
        this.formData={}
        Object.assign(this.formData,row);
        this.formData.kyReplyReason=getElectromeReasons(Number(this.formData.kyReplyReason));
        this.formData.jdReplyReason=getElectromeReasons(Number(this.formData.jdReplyReason));
        this.formData.list1=[row];
        this.assistState=row.assistState;
        this.replaceStatus=row.replaceStatus;
        this.assistCategory =row.assistCategory;	
        this.getOption();
      },
      closed(){
        this.dialogVisible=false;
        this.$parent.isShowDia=false;
      },
      getOption(){

        let group1={
          icon:'',
          sortable:true,
          label: '差异协查与回馈',
          // collapse:false,
          prop: 'group1',
          indexLabel:"#",
          column: [{
            label: '',
            prop: 'list1',
            formslot: true,
          }
          ]
        };
        let group2={
          icon:'',
          sortable:true,
          label: '层级差异协查与回馈',
          // collapse:false,
          prop: 'group2',
          indexLabel:"#",
          column: [{
            label: '',
            prop: 'list2',
            formslot: true,
          }
          ]
        };

        let group3={
          icon:'',
          label: '',
          // collapse:false,
          prop: 'group3',
          column: [{
            label: '归属机电专业回馈差异原因',
            prop: 'jdReplyReason',
            labelWidth:130,
            disabled: true,
            type:'select',
            dicData:electromeReasons(),
          },
            {
              label: '归属车站回馈差异原因',
              prop: 'kyReplyReason',
              labelWidth:130,
              disabled: true,
              type:'select',
              dicData:electromeReasons(),
            },
            {
              label: '机电专业详细描述',
              prop: 'jdReplyDetail',
              type: 'textarea',
              labelWidth:130,
              disabled: true
            },
            {
              label: '车站详细描述',
              prop: 'kyReplyDetail',
              type: 'textarea',
              labelWidth:130,
              disabled: true //回馈过的和替换过的紧张修改
            },
            {
              label: '站长审核意见',
              prop: 'auditStationOpinion',
              type: 'textarea',
              labelWidth:130,
              disabled: true
            },
            {
              label: '车间票务专业审核意见',
              prop: 'auditWorkshopOpinion',
              type: 'textarea',
              labelWidth:130,
              disabled: true
            },
            {
              label: '部门票务专业审核意见',
              prop: 'auditDeptOpinion',
              type: 'textarea',
              labelWidth:130,
              disabled: true
            },
          ]
        };

        this.option={
          submitBtn:false,
          emptyBtn:false,
          span:12,
          group:[]
        } ;
        this.option.group.push(group1);
        // this.option.group.push(group2);
        this.option.group.push(group3);

        this.isReload=false;
        this.$nextTick(()=>{
          this.isReload=true;
        })
      }
    },
    mounted() {

    }
  }
</script>
<style lang="scss">
  .shouPiaoYuanPKCYDXC{
    .shouPiaoYuanPKCYDXCForm{
      .avue-group[index='1']{
        .el-form-item{
          min-width: 450px;
        }
        .avue-form__row{
          width: 100%;
        }
      }

    }
  }

</style>
